package com.qf.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Set;

/**
 * 远程调用 缓存微服务
 * @author lixu
 */
@FeignClient(name = "SMS-PLATFORM-CACHE")
//@RequestMapping("/cache")
public interface CacheFeign {

    @PostMapping("/cache/zadd")
    public boolean zadd(@RequestParam String key,@RequestParam String value,@RequestParam long currentTimeMillis);
    @RequestMapping(value = "/cache/hmget/{key}", method = RequestMethod.GET)
    public Map hMGet(@PathVariable("key") String key);

    @RequestMapping(value = "/cache/hget/{key}/{field}",method = RequestMethod.POST)
    public String hget(@PathVariable(value = "key") String key, @PathVariable(value = "field") String field);


    @RequestMapping(value = "/cache/get/{key}", method = RequestMethod.GET)
    public String get(@PathVariable("key") String key);


    // set结构中的members,获取set中的全部数据
    @RequestMapping(value = "/cache/smembers/{key}",method = RequestMethod.GET)
    public Set<String> smembers(@PathVariable(value = "key") String key);

    // zset结构的根据分数查询数据
    @RequestMapping(value = "/cache/zrangebyscore/{key}",method = RequestMethod.GET)
    public Set<String> zRangeByScore(@PathVariable(value = "key") String key, @RequestParam("min") Long min, @RequestParam(value = "max") Long max);

    // 对hash结构的某一个field进行incr操作
    @PostMapping("/cache/hincr")
    public Long hincr(@RequestParam(value = "key")String key,@RequestParam(value = "field")String field,@RequestParam(value = "delta")Long delta);

    @RequestMapping(value = "/cache/incr", method = RequestMethod.GET)
    public Long incr(@RequestParam("key") String key, @RequestParam("delta") long delta);

    //通配获取key集合
    @GetMapping(value = "/cache/keys/{key}")
    public Set<String> keys(@PathVariable(value = "key")String key);
}
